<?php
/**
 * Created by: i@fedax.cn
 * Date: 2018/7/16 22:40
 */

namespace app\admin\controller;

use app\admin\model\Task as TaskModel;
use app\admin\model\GiftUrl;

/**
 * Task页
 * Class AppManage
 * @package app\admin\controller
 */
class Task extends Index
{
    public function index()
    {
        $data = GiftUrl::all();

        return view()->assign('data',$data);
    }

    /**
     * @return \think\response\Json
     * @throws \think\exception\DbException
     */
    public function taskIndexData()
    {
        $taskModel = new TaskModel();
        $data = $taskModel->getDataList();
        return json($data);
    }

    /**
     * @return \think\response\Redirect
     * @user shuaishuai wu
     * @date 2018/12/19
     * @time 22:42
     * @title task添加
     */
    public function taskAdd()
    {
        $taskModel = new TaskModel();
        $res = $taskModel->add();
        if($res) $this->success(lang('add') . lang('success'));
        else $this->error(lang('add') . lang('false'));
        return redirect('/Miss');
    }

    public function taskEdit()
    {
        $select_data = GiftUrl::all();
        $taskModel = new TaskModel();
        $data = $taskModel->taskEdit();
        return view('edit')->assign(['data'=>$data,'select_data'=>$select_data]);
    }

    public function editData()
    {
        $taskModel = new TaskModel();
        $res = $taskModel->editData();
        return $res;
    }
}